package concurrent.year2021;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class ThreadStateTest3 {


    public static void main(String[] args) throws InterruptedException {

        Lock l1 = new ReentrantLock();
        Lock l2 = new ReentrantLock();

        new Thread(() -> {
            l1.lock();
            try {
                TimeUnit.SECONDS.sleep(3);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            l2.lock(); // WAITING
        }).start();
        l2.lock();
        TimeUnit.SECONDS.sleep(3);
        l1.lock(); // WAITING
    }

}
